<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  div{
    width: 200px;
    height: 200px;
    background: #58a;
  }
</style>
<body>
  <div id="ad"></div>
</body>
<script>
  let color = 0
  //绑定事件
  let ad = document.getElementById('ad')
  ad.onclick = function(){
    console.log(this)
    setTimeout(()=>{
      if(color == 10) color = 0
      color += 1;
      if(color%2==1)this.style.background  = 'pink'
      else this.style.background = '#58a'
    }, 2000)
  }
</script>
</html>
